package com.ws.boot.demo.validate.service.method.parameter.impl;

import com.ws.boot.demo.validate.entity.IdCard;
import com.ws.boot.demo.validate.entity.Person;
import com.ws.boot.demo.validate.entity.Person2;
import com.ws.boot.demo.validate.service.method.parameter.MethodParameterForCheckerService;
import com.ws.boot.demo.validate.validation.groups.Insert;
import com.ws.boot.validate.annotation.constraint.Checker;
import com.ws.boot.validate.groups.Default;
import com.ws.boot.web.domain.DefaultResponse;
import org.springframework.stereotype.Service;

/**
 * 方法参数 业务类 ： Checker 测注解 实现类 .
 *
 * @className: MethodParameterForCheckerServiceImpl
 * @author: ws
 * @date: 2020/4/2 17:49
 * @version: 1.0.0
 */
@Service
public class MethodParameterForCheckerServiceImpl implements MethodParameterForCheckerService {

    /**
     * checker 对应的 POJO .
     *
     * @param idCard
     * @return DefaultResponse
     * @author ws
     * @date 2020/4/2 16:39
     **/
    @Override
    public DefaultResponse checker(@Checker IdCard idCard) {
        return DefaultResponse.success();
    }

    /**
     * checker 对应的 POJO，带分组 .
     *
     * @param idCard
     * @return DefaultResponse
     * @author ws
     * @date 2020/4/2 16:39
     **/
    @Override
    public DefaultResponse checkerGroup(@Checker(groups = Insert.class) IdCard idCard) {
        return DefaultResponse.success();
    }

    /**
     * checker 对应的 Bean,嵌套一层 Bean .
     *
     * @param person
     * @return DefaultResponse
     * @author ws
     * @date 2020/4/3 14:51
     **/
    @Override
    public DefaultResponse checkerNested(@Checker Person person) {
        return DefaultResponse.success();
    }

    /**
     * checker 对应的 Bean,嵌套一层 无 @Checker Bean， .
     *
     * @param person2
     * @return DefaultResponse
     * @author ws
     * @date 2020/4/3 14:51
     **/
    @Override
    public DefaultResponse checkerWithOutNested(@Checker Person2 person2) {
        return DefaultResponse.success();
    }

    /**
     * checker 对应的 POJO，带分组 .
     *
     * @param idCard
     * @return DefaultResponse
     * @author ws
     * @date 2020/4/2 16:39
     **/
    @Override
    public DefaultResponse checkerGroupDefault(@Checker(groups = Default.class) IdCard idCard) {
        return DefaultResponse.success();
    }
}
